package com.longcai.service.impl.property;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.longcai.bean.PageHelper;
import com.longcai.entity.homepage.ClyjHeadlines;
import com.longcai.entity.property.ClyjUserPropertyRecord;
import com.longcai.mapper.clyjheadlines.ClyjHeadlinesMapper;
import com.longcai.mapper.property.ClyjUserPropertyRecordMapper;
import com.longcai.page.table.PageTableResponse;
import com.longcai.service.property.ClyjUserPropertyRecordService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 * 用户资产收益记录表 服务实现类
 * </p>
 *
 * @author M
 * @since 2019-04-15
 */
@Service
public class ClyjUserPropertyRecordServiceImpl extends ServiceImpl<ClyjUserPropertyRecordMapper, ClyjUserPropertyRecord> implements ClyjUserPropertyRecordService {

    private Logger logger = LoggerFactory.getLogger(getClass());
    @Autowired
    private ClyjUserPropertyRecordMapper  clyjUserPropertyRecordMapper;

    /**
     * 获取头条列表
     *
     * @param clyjUserPropertyRecord
     * @param pageHelper
     * @return
     */
    @Override
    public PageTableResponse proList(ClyjUserPropertyRecord clyjUserPropertyRecord, PageHelper pageHelper) {
        //分页
        Page<ClyjUserPropertyRecord> page = new Page<ClyjUserPropertyRecord>(pageHelper.getStart(), pageHelper.getLength());
        QueryWrapper<ClyjUserPropertyRecord> queryWrapper = new QueryWrapper<>();
        if (!StringUtils.isEmpty(clyjUserPropertyRecord.getUserId())) {
            queryWrapper.like("user_id", clyjUserPropertyRecord.getUserId());
        }
        IPage<ClyjUserPropertyRecord> recordIPage = this.clyjUserPropertyRecordMapper.selectPage(page, queryWrapper);
        PageTableResponse pageTableResponse = new PageTableResponse(recordIPage.getTotal(),
                recordIPage.getTotal(), recordIPage.getRecords());
        return pageTableResponse;
    }

}
